﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

namespace ProjectBase.Core
{
    /// <summary>
    ///     Business tier API for set operations
    /// </summary>
    /// <typeparam name = "TEntity">Persitent Entity type</typeparam>
    /// <typeparam name = "TID">the type of the ID property</typeparam>
    [ContractClass(typeof(Diagnostics.WriteFacade<,>))]
    public interface IWriteFacade<TEntity, in TID> : IFacade
        where TEntity : class, IPersistentObjectWithTypedId<TID>
    {
        /// <summary>
        ///     Event rised whenever any write operation is called
        /// </summary>
        event EventHandler Change;

        /// <summary>
        ///     Basic write operation for inserting. Stores only new entity.
        /// </summary>
        /// <param name = "entity">new transient entity</param>
        /// <returns>stored entity with defined identifier ID - or still transient entity if any error arises</returns>
        TEntity Add(TEntity entity);

        /// <summary>
        ///     Basic write operation for changing.
        /// </summary>
        /// <param name = "entity">entity which should be updated</param>
        /// <returns>updated entity - or still transient entity if any error arises</returns>
        TEntity Update(TEntity entity);

        /// <summary>
        ///     Basic write operation for deleting. Definitely removes entity from storage
        /// </summary>
        /// <param name = "entity"></param>
        void Delete(TEntity entity);
    }
}